﻿package Gameplay.Visualizer
{	
	public class Particle 
	{
		private var _x:Number;
        private var _y:Number;
		private var _angle:Number;
        private var _rotPower:Number;
		private var _alpha:Number;
		
        public function get x():Number 
		{ 
			return _x;    
		}
        public function set x(val:Number) : void 
		{
			_x = val;    
		}
        public function get y():Number 
		{ 
			return    _y;    
		}
        public function set y(val:Number) : void 
		{ 
			_y = val;    
		}               
        
        public function get rotPower():Number 
		{ 
			return _rotPower;    
		}
        
        public function get alpha():Number 
		{ 
			return _alpha;    
		}
        
        public function Particle(angle:Number) 
        {            
            _angle = angle;
            _rotPower = 0;
            _alpha = 0;
        }
        
        public function Update(tx:Number, ty:Number, val:Number, angleRate:Number, tempRate:Number ) : void
        {    
            _alpha += val;
            _alpha *= 0.7;
            _rotPower += val + (tempRate * 3);
            _rotPower *= 0.7;
            
            _angle += _rotPower;
            _angle %= 360;
            var rad:Number = _angle * Math.PI / 180;
            _x = tx + Math.cos( rad ) * (angleRate * 200 + 20);
            _y = ty + Math.sin( rad ) * (angleRate * 200 + 20);
        }
	}
	
}
